import request from './request'

// 获取权限列表
export function getPermissionList() {
  return request({
    url: '/api/permission',
    method: 'get'
  })
}

// 创建权限
export function createPermission(data) {
  return request({
    url: '/api/permission',
    method: 'post',
    data
  })
}

// 更新权限
export function updatePermission(permissionId, data) {
  return request({
    url: `/api/permission/${permissionId}`,
    method: 'put',
    data
  })
}

// 删除权限
export function deletePermission(permissionId) {
  return request({
    url: `/api/permission/${permissionId}`,
    method: 'delete'
  })
}

// 切换权限状态
export function togglePermissionStatus(permissionId, isActived) {
  const action = isActived ? 'disable' : 'enable'
  return request({
    url: `/api/permission/${permissionId}/${action}`,
    method: 'post'
  })
} 